/* 初始化数据库 */
const Parse = require('parse/node')

module.exports = async function () {
  // 初始化配置
  await Parse.Config.save({
    title: process.env.TITLE || '系统标题',
  })

  // 初始化管理员用户
  let query = new Parse.Query(Parse.User)
  query.equalTo('username', 'admin')
  let count = await query.count()
  if (count === 0) {
    let user = new Parse.User()
    user.set('name', '管理员')
    user.set('username', 'admin')
    user.set('password', 'e10adc3949ba59abbe56e057f20f883e')
    await user.save()
    console.log('add admin user')
  }
}
